package com.xayy.health.mgt.model;

import cn.kawins.mybatis.base.BaseModel;
import cn.kawins.mybatis.util.SnowflakeId;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.xayy.health.mgt.model.dto.TimeDto;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import tk.mybatis.mapper.annotation.KeySql;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 任务信息
 * 
 * @author houchengwei
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "HEALTH.tb_task_info")
@EqualsAndHashCode(callSuper = true)
public class TaskInfo extends BaseModel<Long> {

    @Id
    @ApiModelProperty(value = "主键")
    @Column(name = "id")
    @KeySql(genId = SnowflakeId.class)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @ApiModelProperty(value = "图例名称")
    @Column(name = "legend_name")
    private String legendName;


    @ApiModelProperty(value = "是否是批量上传 0是1不是")
    @Column(name = "is_batch")
    private Integer isBatch;

    @ApiModelProperty(value = "任务名称")
    @Column(name = "name")
    private String name;

    @Column(name = "type")
    @ApiModelProperty(value = "任务类型", notes = "1：数据处理2：事后诊断3：趋势预测")
    private Integer type;

    @ApiModelProperty(value = "卫星代号")
    @Column(name = "satellite_code")
    private String satelliteCode;

    @ApiModelProperty(value = "参数")
    @Column(name = "json_params")
    private String params;

    @ApiModelProperty(value = "剔野方法")
    @Column(name = "ty_tag")
    private String tyTag;

    @ApiModelProperty(value = "填充方法")
    @Column(name = "tc_tag")
    private String tcTag;

    @ApiModelProperty(value = "平滑方法")
    @Column(name = "ph_tag")
    private String phTag;

    @Column(name = "model_name")
    @ApiModelProperty(value = "模型名称", notes = "在事后诊断和趋势预测的自动运行创建任务时候用到")
    private String modelName;

    @ApiModelProperty(value = "处理周期")
    @Column(name = "cycle")
    private String cycle;

    @ApiModelProperty(value = "开始时间")
    @Column(name = "start_time")
    private Date startTime;

    @ApiModelProperty(value = "结束时间")
    @Column(name = "end_time")
    private Date endTime;

    @Column(name = "pred_number")
    @ApiModelProperty(value = "预测多少个点")
    private Integer predNumber;

    @Column(name = "time_span")
    @ApiModelProperty(value = "预测间隔")
    private Integer timeSpan;

    @Column(name = "status")
    @ApiModelProperty(value = "状态0：不运行1：运行")
    private Integer status;

    @Column(name = "time_interval")
    @ApiModelProperty(value = "数据采样间隔")
    private Integer timeInterval;

    @Column(name = "is_current_params")
    @ApiModelProperty(value = "是否是当前参数模型 1:是 0：不是")
    private Integer isCurrentParams;

    @ApiModelProperty(value = "多参数算法名称（存的是id）")
    @Column(name = "multiparameter_alg_name")
    private String multiparameterAlgName;

    /**
     * 均值需要的参数   pointNum，sampleTime，interval，probability
     */
    @ApiModelProperty(value = "连续取点个数")
    @Column(name = "point_num")
    private String pointNum;

    @ApiModelProperty(value = "取值时间")
    @Column(name = "sample_time")
    private String sampleTime;

    @ApiModelProperty(value = "间隔点数")
    @Column(name = "interval_num")
    private String intervalNum;

    @ApiModelProperty(value = "概率")
    @Column(name = "probability")
    private String probability;

    @ApiModelProperty(value = "偏差比")
    @Column(name = "deviate")
    private String deviate;

    @ApiModelProperty(value = "均值特征传递的json数据")
    private Map<String, Object> telemetryDataList;

    /**
     * 双参数（使用）
     */
    @Column(name = "normal_start_time")
    @ApiModelProperty(value = "正常开始时间")
    private Date normalStartTime;

    @Column(name = "normal_end_time")
    @ApiModelProperty(value = "正常结束时间")
    private Date normalEndTime;

    @ApiModelProperty(value = "是否多参数 1true是 0false否")
    @Column(name = "check_multiparameter")
    private Integer checkMultiparameter;

    @ApiModelProperty(value = "参数名称")
    @Column(name = "param_code_name")
    private String paramCodeName;

    @Column(name = "algorithm_name")
    @ApiModelProperty(value = "算法名称")
    private String algorithmName;

    @Transient
    @ApiModelProperty(value = "算法列表(预处理)")
    private String algorithmNameList;

    @ApiModelProperty(value = "偏差值")
    private String compare;

    @ApiModelProperty(value = "学习多段时间", required = true)
    private List<TimeDto> learnMultiTerminalTime;

    @ApiModelProperty(value = "检测时间", required = true)
    private TimeDto verifyTime;

    @ApiModelProperty(value = "是否是案例一", required = true)
    @Column(name = "is_case_one")
    private Integer isCaseOne;

    @ApiModelProperty(value = "案例一判断是否是第一次")
    @Column(name = "is_first")
    private Integer isFirst;

    @ApiModelProperty(value = "案例一最后一个时间")
    @Column(name = "date_end_time")
    private Date dateEndTime;

    @ApiModelProperty(value = "门限值")
    @Column(name = "threshold")
    private String threshold;

    @ApiModelProperty(value = "算法是否存在异常情况 0否1是")
    @Column(name = "error_situation")
    private String errorSituation;

    @ApiModelProperty(value = "运行状态 1长期运行2阶段性运行")
    @Column(name = "running_status")
    private Integer runningStatus;


    @ApiModelProperty(value = "长期运行结束时间")
    @Column(name = "long_running_time")
    private Date longRunningTime;


    @ApiModelProperty(value = "阶段运行结束时间")
    @Column(name = "run_in_stages_time")
    private Date runInStagesTime;

    @ApiModelProperty(value = "步长")
    @Column(name = "step")
    private String step;


    @ApiModelProperty(value = "图例id")
    private Long fileLogo;

    @ApiModelProperty(value = "数据来源：0：原始,1：处理后数据")
    @Column(name = "original_data_sources")
    private Integer originalDataSources;

    @ApiModelProperty(value = "任务暂停到何时")
    @Column(name = "pause_end_time")
    private Date pauseEndTime;

    @ApiModelProperty(value = "任务暂停到何时是否已经执行过:1已执行，其他未执行")
    @Column(name = "pause_end_time_is_execute")
    private Integer pauseEndTimeIsExecute;

    @ApiModelProperty(value = "定时任务cron表达式")
    @Column(name = "cron")
    private String cron;

    @Override
    public Long idValue() {
        return id;
    }

}
